package 二维数组中的查找;

public class Solution {
    public boolean Find(int target, int [][] array)
    {
        if (array==null)
            return false;
        int rows=array.length;
        int columns=array[0].length;

        boolean found=false;

        int row=0;
        int column=columns-1;
        while(row<rows&&column>=0)
        {
            if (array[row][column]==target)
            {
                found=true;
                break;
            }
            else if (array[row][column]>target)
            {
                column--;
            }
            else
            {
                row++;
            }
        }
        return found;
    }

    public static void main(String[] args)
    {
        int[][] test={{1,2,8,9},{2,4,9,12},{4,7,10,13},{6,8,11,15}};
        Solution solution = new Solution();
        System.out.println(solution.Find(7,test));
    }
}
